#ifndef __GRAPH_H__
#define __GRAPH_H__

#include <vector>
#include <map>
#include "math.h"

#include "micropather.h"

#include "cNode.h"

using namespace std;
using namespace micropather;

typedef map<std::string, cNode*> NodeMap;
typedef pair<std::string, cNode*> NodePair;

class cGraph : public Graph
{
public:
	cGraph(void);
	~cGraph(void);

	//
	// Graph data
	//
	bool cGraph::Load(char* filename);
	void cGraph::Unload();

	NodeMap* GetNodeMap(){return &nodes;};
	float ComputeLinearCost(cNode* start, cNode* end);

	//
	// *** micropather ***
	//
	virtual float LeastCostEstimate( void* stateStart, void* stateEnd );
	virtual void AdjacentCost( void* state, vector< StateCost > *adjacent );
	virtual void PrintStateInfo( void* state );

	int Find( cNode* startNode, cNode* endNode, vector< void* >* path, float* cost );
	int Find( int start_x, int start_y, int end_x, int end_y, vector< void* >* path, float* cost );

private:
	MicroPather *pather;
	NodeMap nodes;

	float LinearCost(int start_x, int start_y, int end_x, int end_y);
	cNode* FindClosestNode(int start_x, int start_y, float* cost, bool* nodeExists);
};

#endif